import React from 'react'
import { Form, Table, Icon, Tag, Modal } from 'antd'
import { DropOption } from 'components'
import styles from './List.less'
import moment from "moment"
const confirm = Modal.confirm

class ModalSelect extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			current: 0,
		};
	}

	edit = (record, e, text) => {
		//	console.log(record)
		//	console.log(e)
		//	console.log(text)
		const { showDetail, onDeleteItem, onComponent, onEidt, onSearch } = this.props
		if (e == 1) {
			//		alert("1")
			showDetail(record.number)
		} else if (e == 2) {
			window.location = "/file/newfile?" + record.number
		} else if (e == 3) {
			confirm({
				title: '您确定要删除这条记录吗?',
				onOk() {
					onDeleteItem(record.number)
				}
			})
		} else if (e == 4) {
			confirm({
				title: '您确定要归档这条记录吗?',
				onOk() {
					if (record.state == 0) {
						onComponent(record.number, 1)
					}
					if (record.state == 1) {
						onComponent(record.number, 2)
					}

				}
			})
		} else if (e == 5) {
			onEidt(record.number, record.organizationId)
		}
	}
	showList() {
		const { onList } = this.props
		onList()
	}
	async pageChange(pagination) {
		//  console.log(pagination);
		await this.props.onPageChange(pagination);
		this.newPage = pagination.current;
	}
	render() {
		const { loading, pagination2, onPageChange, showDetail, list, listDetais } = this.props;
		//		console.log(list)
		//		console.log(listDetais)
		const datas = [{
			key: '1',
			number: '胡彦斌',
			title: '测试',
			type: '测试的',
			state: 1,
			department: '部门1',
			person: '管理1',
			time: '2018-03-02',
			title: '西湖区湖底公园1号'
		}];
		const columns = [
			{
				title: "档案年度",
				dataIndex: "documentYear",
				key: "documentYear",
			}, {
				title: "公证事项",
				dataIndex: "notarialMatters",
				key: "notarialMatters",
			},
			{
				title: "申请人",
				dataIndex: "applyName",
				key: "applyName",
			},
			{
				title: "收件日期",
				dataIndex: "createdTime",
				key: "createdTime",
				render: (text, record) => {
					return (
						<p>
							{
								moment(record.createdTime).format("YYYY-MM-DD")
							}
						</p>
					)
				}
			},
			{
				title: "公证日期",
				dataIndex: "notarizationAt",
				key: "notarizationAt",
				render: (text, record) => {
					return (
						<p>
							{
								moment(record.notarizationAt).format("YYYY-MM-DD")
							}
						</p>
					)
				}
			},
			{
				title: "承办人",
				dataIndex: "contractorUserName",
				key: "contractorUserName",
			},
			{
				title: "建档人",
				dataIndex: "createdUserName",
				key: "createdUserName",
			},
			{
				title: "所属机构",
				dataIndex: "organizationName",
				key: "organizationName",
			}
			// , {
			// 	title: '操作',
			// 	key: 'operation',
			// 	render: (text, record) => {
			// 		return (
			// 			<div>
			// 				<span onClick={this.edit.bind(null, record, 1)} style={{ marginRight: 5 }}><a href="#">查看</a></span>
			// 				<span onClick={this.edit.bind(null, record, 2)} style={{ marginRight: 5 }}><a href="#">修改</a></span>
			// 				<span onClick={this.edit.bind(null, record, 3)} style={{ marginRight: 5 }}><a href="#">删除</a></span>
			// 				{record.state == "0" ?
			// 					<span onClick={this.edit.bind(null, record, 4)} style={{ marginRight: 5 }}><a href="#">归档</a></span> :
			// 					record.state == "1" ?
			// 						<span onClick={this.edit.bind(null, record, 4)} style={{ marginRight: 5 }}><a href="#">历史归档</a></span> :
			// 						""
			// 				}
			// 				<span onClick={this.edit.bind(null, record, 5)} style={{ marginRight: 5 }}><a href="#">移交</a></span>
			// 			</div>
			// 		)
			// 	}
			// }

		];

		return (
			<div>
				<div onClick={this.showList.bind(this)}>
					<a href="#">文档统计</a>
				</div>
				<Table
					columns={columns}
					dataSource={listDetais}
					loading={loading}
					onChange={this.pageChange.bind(this)}
					pagination={pagination2}
					rowKey={record => record.endAt}
				/>
			</div>
		)
	}


}

export default Form.create()(ModalSelect)
